package com.qf.lanzhou.shop.admin.controller;

import com.qf.lanzhou.shop.admin.service.ChartService;
import com.qf.lanzhou.shop.pojo.entity.ChartPie;
import com.qf.lanzhou.shop.pojo.entity.Seller;
import com.qf.lanzhou.shop.pojo.qo.OrderDataQo;
import com.qf.lanzhou.shop.pojo.vo.BaseRespVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author LEON-HE
 */
@Api(tags = "报表接口")
@Controller
@RequestMapping("/chart")
public class ChartController extends BaseController {

    @Autowired
    private ChartService chartService;

    @RequestMapping(value = "/pie", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取饼形图数据")
    public BaseRespVO getChartPie(HttpServletRequest req){
        Seller seller = (Seller) req.getSession().getAttribute("seller");
        List<ChartPie> pieData = chartService.getPieData(seller.getId());
        return convertSuccessResult(pieData);
    }

    @RequestMapping(value = "/orderData", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取商家日数据")
    public BaseRespVO getShopD(HttpServletRequest req){
        Seller seller = (Seller) req.getSession().getAttribute("seller");
        OrderDataQo orderData = chartService.getOrderData(seller.getId());
        return convertSuccessResult(orderData);
    }

    @RequestMapping(value = "/weekData", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取线性图数据")
    public BaseRespVO getWeekAmount(HttpServletRequest req){
        Seller seller = (Seller) req.getSession().getAttribute("seller");
        List<BigDecimal> weekAmount = chartService.getWeekAmount(seller.getId());
        return convertSuccessResult(weekAmount);
    }

}
